package com.sino.dataworks.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import com.sun.mail.util.MailSSLSocketFactory;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.GeneralSecurityException;

public class SendMailUtil {
   static MailAccount account=null;
    static {
        account = new MailAccount();
        account.setHost("172.28.71.58");
        account.setPort(25);
        account.setAuth(true);
    //    account.setSslEnable(true);
        account.setFrom("zxcx@cheryfs.cn");
        account.setUser("zxcx@cheryfs.cn");
        account.setPass("Zxcx!@#123");
        account.setCustomProperty("mail.smtp.localhost","192.168.10.7");
        account.setCustomProperty("mail.smtp.bindaddress","192.168.10.7");
        MailSSLSocketFactory sf = null;
        try {
            sf = new MailSSLSocketFactory();
        } catch (GeneralSecurityException e) {
            throw new RuntimeException(e);
        }
        sf.setTrustAllHosts(true);
        account.setCustomProperty("mail.smtp.ssl.socketFactory", sf);
    }

    public static void sendMail(String to,String cp, String subject, String content) {
        MailUtil.send(account, CollUtil.newArrayList("wangxd@sino-bridge.com"),CollUtil.newArrayList("944271466@qq.com"),null, subject,content, true);
    }


}



